<!DOCTYPE html>
<html>
<head>
    <style>
        body {
            margin: 0;
            padding: 0;
            overflow: hidden;
            background: transparent;
            -webkit-app-region: drag; /* 整个窗口可拖动 */
        }
        #floatingBtn {
            width: 50px;
            height: 50px;
            background-color: #1890ff;
            border: none;
            border-radius: 25px;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            transition: background-color 0.3s;
            -webkit-app-region: no-drag; /* 按钮本身不可拖动 */
        }
        #floatingBtn:hover {
            background-color: #40a9ff;
        }
    </style>
</head>
<body>
    <button id="floatingBtn">▶</button>
    <script>
        const { ipcRenderer } = require('electron');
        const { getCurrentWindow } = require('@electron/remote');
        
        document.getElementById('floatingBtn').addEventListener('click', () => {
            ipcRenderer.send('show-main-window');
        });

        // 使用更简单的拖动实现
        let isDragging = false;
        let startPosition = { x: 0, y: 0 };
        let startWindowPosition = { x: 0, y: 0 };

        document.addEventListener('mousedown', (e) => {
            isDragging = true;
            startPosition = { x: e.screenX, y: e.screenY };
            const win = getCurrentWindow();
            const [winX, winY] = win.getPosition();
            startWindowPosition = { x: winX, y: winY };
        });

        document.addEventListener('mousemove', (e) => {
            if (!isDragging) return;
            
            const win = getCurrentWindow();
            const newX = startWindowPosition.x + (e.screenX - startPosition.x);
            const newY = startWindowPosition.y + (e.screenY - startPosition.y);
            
            win.setPosition(newX, newY);
        });

        document.addEventListener('mouseup', () => {
            isDragging = false;
        });
    </script>
</body>
</html>